import { EnterpriseInfo, GetBusinessInfo, SubBusiness } from './types';
import request from '../../request';

export function getEnterpriseInfo() {
  return request.get<EnterpriseInfo>({
    url: '/org/getAllOrg',
    interceptors: {
      responseInterceptor(res: any): EnterpriseInfo {
        return {
          ...res,
        };
      },
    },
  });
}

export function editCompanyUserInfo() {
  return request.post<EnterpriseInfo>({
    url: '/org/editOrg',
    interceptors: {
      responseInterceptor(res: any): EnterpriseInfo {
        return {
          ...res.data,
        };
      },
    },
  });
}

// 提交企业信息
export function subBusinessInfo(data: {
  sysOrg: {
    address: string;
    area: string;
    comment: string;
    id: number;
    industry: string;
    name: string;
    scale: string;
    status: number;
  };
}) {
  return request.post<SubBusiness>({
    url: '/org/editOrg',
    data,
    interceptors: {
      responseInterceptor(res: any): SubBusiness {
        return {
          ...res,
        };
      },
    },
  });
}

// 获取企业信息
export function gettBusinessInfo() {
  return request.get<GetBusinessInfo>({
    url: '/org/getOrg',
    interceptors: {
      responseInterceptor(res: any): GetBusinessInfo {
        return {
          ...res,
        };
      },
    },
  });
}

// 改变企业头像
export function changeAvatar(params: { avatar: string; id: number }) {
  return request.post<any>({
    url: '/org/editAvatar',
    params,
    interceptors: {
      responseInterceptor(res: any): any {
        return res;
      },
    },
  });
}
